package mx.com.mindbits.bandpay.business;

import mx.com.mindbits.bandpay.dao.UsersDAO;
import mx.com.mindbits.bandpay.utils.ConstantsValues;
import mx.com.mindbits.bandpay.vo.UserVO;
import mx.com.mindbits.dao.users;
import android.content.Context;
import android.util.Log;

public class UserBusiness {
	
	private UsersDAO _userDao; 
	private Context _context;
	
	public UserBusiness(Context context){
		_context = context;
		_userDao = new UsersDAO(context);
	}
	
	public boolean insertUser(UserVO _userVO) throws Exception{
		users user = new users();
		
		user.setId_user(null);
		user.setUser_name(_userVO.getNombre());
		user.setUser_password(_userVO.getPassword());
		user.setUser_email(_userVO.getEmail());
		user.setUser_mail_pass(_userVO.getPass_email());
		user.setHost(_userVO.getHost());
		user.setPort(_userVO.getPort());
		user.setLink_privacity(_userVO.getLink());
		
		Log.i(ConstantsValues.TAG_DAO,"bu"+user.getUser_email());
		return _userDao.insertUser(user);
	}
	
	public boolean updateUser(UserVO _userVO,Long id){
		users user = new users();
		
		user.setId_user(id);
		user.setUser_name(_userVO.getNombre());
		user.setUser_password(_userVO.getPassword());
		user.setUser_email(_userVO.getEmail());
		user.setUser_mail_pass(_userVO.getPass_email());
		user.setHost(_userVO.getHost());
		user.setPort(_userVO.getPort());
		user.setLink_privacity(_userVO.getLink());
		
		Log.i(ConstantsValues.TAG_DAO,"i"+user.getUser_email());
		return _userDao.updateUser(user);
	}
	
	
	
}